<template>
  <el-dialog v-model="dialogFormVisible" :title="title" @close="closeDialog">
    <el-form :model="addBaseStudentForm" ref="addBaseStudentRef" :rules="addBaseStudentrules">
      <el-form-item label="学生姓名" :label-width="formLabelWidth" prop="name">
        <el-input v-if="addBaseStudentForm.id > 0" disabled v-model="addBaseStudentForm.name" autocomplete="off"
          ref="name" placeholder="请填写学生姓名"></el-input>
        <el-input v-if="!addBaseStudentForm.id" v-model="addBaseStudentForm.name" autocomplete="off" ref="name"
          placeholder="请填写学生姓名"></el-input>
      </el-form-item>
      <el-form-item label="所在年级" :label-width="formLabelWidth" prop="gradeId">
        <el-select v-model="addBaseStudentForm.gradeId" autocomplete="off" @change="filterGradeId"
          placeholder="请选择所在年级">
          <el-option v-for="gradeId in gradeIds" :key="gradeId" :value="gradeId"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="所在班级" :label-width="formLabelWidth" v-if="addBaseStudentForm.gradeId != ''" prop="classId">
        <el-select v-model="addBaseStudentForm.classId" autocomplete="off" placeholder="请选择所在班级">
          <el-option v-for="item in classInfos" :key="item.classId" :value="item.classId"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="学生性别" :label-width="formLabelWidth" prop="sex">
        <el-select v-model="addBaseStudentForm.sex" autocomplete="off" ref="name" placeholder="请选择学生性别">
          <el-option label="男" :value="1"></el-option>
          <el-option label="女" :value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="联系电话" :label-width="formLabelWidth" prop="addBaseStudentForm.mobile">
        <el-input v-model="addBaseStudentForm.mobile" autocomplete="off" ref="name" placeholder="请填写联系电话"></el-input>
      </el-form-item>
      <el-form-item label="身份证号" :label-width="formLabelWidth" prop="addBaseStudentForm.idCard">
        <el-input v-model="addBaseStudentForm.idCard" autocomplete="off" ref="name" placeholder="请填写身份证号"></el-input>
      </el-form-item>

      <el-form-item label="学生状态" :label-width="formLabelWidth" prop="status">
        <el-select v-model="addBaseStudentForm.status" autocomplete="off" ref="name" placeholder="请选择学生状态">
          <el-option label="在读" :value="0"></el-option>
          <el-option label="休学" :value="2"></el-option>
          <el-option label="退学" :value="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="校区" :label-width="formLabelWidth" prop="campus">
        <el-select v-model="addBaseStudentForm.campus" autocomplete="off" ref="name" placeholder="请选择校区">
          <el-option :label="campusName" :value="1"></el-option>
          <el-option :label="campusName1" :value="2"></el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="选科类型" :label-width="formLabelWidth"
                                      prop="modeSubject" v-if="addBaseStudentForm.id">
                            <el-input
                                    v-model="addBaseStudentForm.modeSubject"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写选科类型"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="" :label-width="formLabelWidth"
                                      prop="studentNumber">
                            <el-input
                                    v-model="addBaseStudentForm.studentNumber"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="" :label-width="formLabelWidth"
                                      prop="password">
                            <el-input
                                    v-model="addBaseStudentForm.password"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写"
                            ></el-input>
                        </el-form-item> -->

      <!-- <el-form-item label="考生号" :label-width="formLabelWidth"
                                      prop="examineNumber">
                            <el-input
                                    v-model="addBaseStudentForm.examineNumber"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写考生号"
                            ></el-input>
                        </el-form-item> -->

      <!-- <el-form-item label="父亲手机号" :label-width="formLabelWidth"
                                      prop="fatherMobile">
                            <el-input
                                    v-model="addBaseStudentForm.fatherMobile"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写父亲手机号"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="母亲手机号" :label-width="formLabelWidth"
                                      prop="motherMobile">
                            <el-input
                                    v-model="addBaseStudentForm.motherMobile"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写母亲手机号"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="父亲姓名" :label-width="formLabelWidth"
                                      prop="fatherName">
                            <el-input
                                    v-model="addBaseStudentForm.fatherName"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写父亲姓名"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="母亲姓名" :label-width="formLabelWidth"
                                      prop="motherName">
                            <el-input
                                    v-model="addBaseStudentForm.motherName"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写母亲姓名"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="地址" :label-width="formLabelWidth"
                                      prop="address">
                            <el-input
                                    v-model="addBaseStudentForm.address"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写地址"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="父亲工作单位" :label-width="formLabelWidth"
                                      prop="fatherWorkUnit">
                            <el-input
                                    v-model="addBaseStudentForm.fatherWorkUnit"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写父亲工作单位"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="母亲工作单位" :label-width="formLabelWidth"
                                      prop="motherWorkUnit">
                            <el-input
                                    v-model="addBaseStudentForm.motherWorkUnit"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写母亲工作单位"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label=" 是否可用" :label-width="formLabelWidth"
                                      prop="status" v-if="addBaseStudentForm.id">
                            <el-input
                                    v-model="addBaseStudentForm.status"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写 是否可用"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="创建人id" :label-width="formLabelWidth"
                                      prop="createId" v-if="addBaseStudentForm.id">
                            <el-input
                                    v-model="addBaseStudentForm.createId"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写创建人id"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="创建时间" :label-width="formLabelWidth"
                                      prop="createDate" v-if="addBaseStudentForm.id">
                            <el-input
                                    v-model="addBaseStudentForm.createDate"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写创建时间"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="班级id" :label-width="formLabelWidth"
                                      prop="classId" v-if="addBaseStudentForm.id">
                            <el-input
                                    v-model="addBaseStudentForm.classId"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写班级id"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="年级id" :label-width="formLabelWidth"
                                      prop="gradeId" v-if="addBaseStudentForm.id">
                            <el-input
                                    v-model="addBaseStudentForm.gradeId"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写年级id"
                            ></el-input>
                        </el-form-item> -->

      <!-- <el-form-item label="别名" :label-width="formLabelWidth"
                                      prop="alias">
                            <el-input
                                    v-model="addBaseStudentForm.alias"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写别名"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="个人照片" :label-width="formLabelWidth"
                                      prop="photo">
                            <el-input
                                    v-model="addBaseStudentForm.photo"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写个人照片"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="政治面貌" :label-width="formLabelWidth"
                                      prop="politicalOutlook">
                            <el-input
                                    v-model="addBaseStudentForm.politicalOutlook"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写政治面貌"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="入党/团日期" :label-width="formLabelWidth"
                                      prop="incomeDate">
                            <el-input
                                    v-model="addBaseStudentForm.incomeDate"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写入党/团日期"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="民族" :label-width="formLabelWidth"
                                      prop="nation">
                            <el-input
                                    v-model="addBaseStudentForm.nation"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写民族"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="原毕业学校" :label-width="formLabelWidth"
                                      prop="graduateSchool">
                            <el-input
                                    v-model="addBaseStudentForm.graduateSchool"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写原毕业学校"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="入学成绩" :label-width="formLabelWidth"
                                      prop="admissionScore">
                            <el-input
                                    v-model="addBaseStudentForm.admissionScore"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写入学成绩"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="学生类型" :label-width="formLabelWidth"
                                      prop="type">
                            <el-input
                                    v-model="addBaseStudentForm.type"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写学生类型"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="招生注册号" :label-width="formLabelWidth"
                                      prop="incomeCode">
                            <el-input
                                    v-model="addBaseStudentForm.incomeCode"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写招生注册号"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="曾用名" :label-width="formLabelWidth"
                                      prop="beforeName">
                            <el-input
                                    v-model="addBaseStudentForm.beforeName"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写曾用名"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="国籍" :label-width="formLabelWidth"
                                      prop="nationality">
                            <el-input
                                    v-model="addBaseStudentForm.nationality"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写国籍"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="就读方式" :label-width="formLabelWidth"
                                      prop="modeStudy">
                            <el-input
                                    v-model="addBaseStudentForm.modeStudy"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写就读方式"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="一卡通卡号" :label-width="formLabelWidth"
                                      prop="oneCardNumber">
                            <el-input
                                    v-model="addBaseStudentForm.oneCardNumber"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写一卡通卡号"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="宿舍编号" :label-width="formLabelWidth"
                                      prop="dormitoryNumber">
                            <el-input
                                    v-model="addBaseStudentForm.dormitoryNumber"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写宿舍编号"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="" :label-width="formLabelWidth"
                                      prop="englishName">
                            <el-input
                                    v-model="addBaseStudentForm.englishName"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="学生类型" :label-width="formLabelWidth"
                                      prop="studentType" v-if="addBaseStudentForm.id">
                            <el-input
                                    v-model="addBaseStudentForm.studentType"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写学生类型"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="校区、默认主校区" :label-width="formLabelWidth"
                                      prop="campus" v-if="addBaseStudentForm.id">
                            <el-input
                                    v-model="addBaseStudentForm.campus"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写校区、默认主校区"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="统计成绩" :label-width="formLabelWidth"
                                      prop="scoreStatistics" v-if="addBaseStudentForm.id">
                            <el-input
                                    v-model="addBaseStudentForm.scoreStatistics"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写统计成绩"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="就读方式" :label-width="formLabelWidth"
                                      prop="modeOfStudy" v-if="addBaseStudentForm.id">
                            <el-input
                                    v-model="addBaseStudentForm.modeOfStudy"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写就读方式"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="" :label-width="formLabelWidth"
                                      prop="isDelete" v-if="addBaseStudentForm.id">
                            <el-input
                                    v-model="addBaseStudentForm.isDelete"
                                    autocomplete="off"
                                    ref="name"
                                    placeholder="请填写"
                            ></el-input>
                        </el-form-item> -->
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="cancel()">取消</el-button>
        <el-button type="primary" @click="save()">保存</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import { ref } from "vue";
import { httpService } from "@/utils/httpService";
import { ElMessage, ElForm, ElMessageBox } from "element-plus";
import { vxRule } from "@/utils/validator";
import { decrypt } from "@/utils/dateFormat";
import { API_BASE_NAME2, API_BASE_NAME3, } from '../../constants';

export default {
  name: "AddBaseStudent",
  components: { ElForm, ElMessage, ElMessageBox },
  data() {
    return {
      campusName: API_BASE_NAME2,
      campusName1: API_BASE_NAME3,
      dialogFormVisible: ref(false),
      formLabelWidth: "120px",
      title: "",
      personnelType: "",
      gradeIds: [],
      classInfos: [],
      map: {},
      oldGradeId: "",
      personalCard: '',
      phoneNumber: '',
      addBaseStudentForm: {
        modeSubject: "",
        studentNumber: "",
        password: "",
        name: "",
        examineNumber: "",
        idCard: "",
        sex: "",
        fatherMobile: "",
        motherMobile: "",
        fatherName: "",
        motherName: "",
        address: "",
        fatherWorkUnit: "",
        motherWorkUnit: "",
        status: "",
        createId: "",
        createDate: "",
        classId: "",
        gradeId: "",
        mobile: "",
        alias: "",
        photo: "",
        politicalOutlook: "",
        incomeDate: "",
        nation: "",
        graduateSchool: "",
        admissionScore: "",
        type: 0,
        incomeCode: "",
        beforeName: "",
        nationality: "",
        modeStudy: "",
        oneCardNumber: "",
        dormitoryNumber: "",
        englishName: "",
        studentType: "",
        campus: "",
        scoreStatistics: "",
        modeOfStudy: "",
        isDelete: "",
      },
      // 校验规则
      addBaseStudentrules: {
        studentNumber: vxRule(true, null, "blur"),
        sex: vxRule(true, null, "blur"),
        name: vxRule(true, null, "blur"),
        gradeId: vxRule(true, null, "blur"),
        classId: vxRule(true, null, "blur"),
        motherMobile: vxRule(true, null, "blur"),
        fatherName: vxRule(true, null, "blur"),
        motherName: vxRule(true, null, "blur"),
        address: vxRule(true, null, "blur"),
        fatherWorkUnit: vxRule(true, null, "blur"),
        motherWorkUnit: vxRule(true, null, "blur"),
        alias: vxRule(true, null, "blur"),
        photo: vxRule(true, null, "blur"),
        politicalOutlook: vxRule(true, null, "blur"),
        incomeDate: vxRule(true, null, "blur"),
        nation: vxRule(true, null, "blur"),
        graduateSchool: vxRule(true, null, "blur"),
        admissionScore: vxRule(true, null, "blur"),
        type: vxRule(true, null, "blur"),
        incomeCode: vxRule(true, null, "blur"),
        beforeName: vxRule(true, null, "blur"),
        nationality: vxRule(true, null, "blur"),
        modeStudy: vxRule(true, null, "blur"),
        oneCardNumber: vxRule(true, null, "blur"),
        dormitoryNumber: vxRule(true, null, "blur"),
        englishName: vxRule(true, null, "blur"),
        campus: vxRule(true, null, "blur"),
      },
    };
  },
  methods: {
    closeDialog() {
      this.clear();
    },
    getBasedecrypt(str, number) {
      // console.log(str,number);
      let params = new FormData()
      params.append('encryptedData', number)
      httpService("/javaApi/crypto/decrypt", params, "post").then(
        (data) => {
          if (str == '身份证') {
            this.addBaseStudentForm.idCard = data
          } else if (str == '电话') {
            this.addBaseStudentForm.mobile = data
          }
          // console.log(data);
        }
      );
    },
    getBaseClassInfoList() {
      httpService("/javaApi/baseClassInfo/getAllEffectClass", {}, "get").then(
        (data) => {
          this.map = data;
          if (this.addBaseStudentForm.gradeId != "") {
            this.classInfos = this.map[this.addBaseStudentForm.gradeId];
          }
        }
      );
    },
    cancel() {
      this.dialogFormVisible = false;
      this.clear();
    },
    getBaseStudentById(id) {
      httpService("/javaApi/baseStudent/queryById", { id: id }, "get").then(
        (data) => {
          // console.log(123, data.idCard);
          this.getBasedecrypt("身份证", data.idCard)
          this.getBasedecrypt("电话", data.mobile)

          data.type = parseInt(data.type);
          this.addBaseStudentForm = data;
          this.oldGradeId = data.gradeId;

          // this.addBaseStudentForm.idCard = decrypt(this.addBaseStudentForm.idCard)
          // this.addBaseStudentForm.mobile = decrypt(this.addBaseStudentForm.mobile)
          // console.log(123123, this.addBaseStudentForm.idCard, this.addBaseStudentForm.mobile);
        }
      );
    },
    getGradeIds() {
      let date = new Date();
      let nowYear = parseInt(date.getFullYear());
      let nowMonth = parseInt(date.getMonth() + 1);
      let gradeIds = [];
      if (nowMonth > 6) {
        gradeIds.push(nowYear - 2);
        gradeIds.push(nowYear - 1);
        gradeIds.push(nowYear);
      } else {
        gradeIds.push(nowYear - 3);
        gradeIds.push(nowYear - 2);
        gradeIds.push(nowYear - 1);
      }
      this.gradeIds = gradeIds;
    },
    filterGradeId(val) {
      this.classInfos = this.map[val];
      this.addBaseStudentForm.classId = '';
    },
    clear() {
      this.dialogFormVisible = false;
      //清空form
      this.addBaseStudentForm.modeSubject = "";
      this.addBaseStudentForm.id = "";
      this.addBaseStudentForm.studentNumber = "";
      this.addBaseStudentForm.password = "";
      this.addBaseStudentForm.name = "";
      this.addBaseStudentForm.examineNumber = "";
      this.addBaseStudentForm.idCard = "";
      this.addBaseStudentForm.sex = "";
      this.addBaseStudentForm.fatherMobile = "";
      this.addBaseStudentForm.motherMobile = "";
      this.addBaseStudentForm.fatherName = "";
      this.addBaseStudentForm.motherName = "";
      this.addBaseStudentForm.address = "";
      this.addBaseStudentForm.fatherWorkUnit = "";
      this.addBaseStudentForm.motherWorkUnit = "";
      this.addBaseStudentForm.status = "";
      this.addBaseStudentForm.createId = "";
      this.addBaseStudentForm.createDate = "";
      this.addBaseStudentForm.classId = "";
      this.addBaseStudentForm.gradeId = "";
      this.addBaseStudentForm.mobile = "";
      this.addBaseStudentForm.alias = "";
      this.addBaseStudentForm.photo = "";
      this.addBaseStudentForm.politicalOutlook = "";
      this.addBaseStudentForm.incomeDate = "";
      this.addBaseStudentForm.nation = "";
      this.addBaseStudentForm.graduateSchool = "";
      this.addBaseStudentForm.admissionScore = "";
      this.addBaseStudentForm.type = "";
      this.addBaseStudentForm.incomeCode = "";
      this.addBaseStudentForm.beforeName = "";
      this.addBaseStudentForm.nationality = "";
      this.addBaseStudentForm.modeStudy = "";
      this.addBaseStudentForm.oneCardNumber = "";
      this.addBaseStudentForm.dormitoryNumber = "";
      this.addBaseStudentForm.englishName = "";
      this.addBaseStudentForm.studentType = "";
      this.addBaseStudentForm.campus = "";
      this.addBaseStudentForm.scoreStatistics = "";
      this.addBaseStudentForm.modeOfStudy = "";
      this.addBaseStudentForm.isDelete = "";
      this.personalCard = "";
      this.phoneNumber = "";
    },
    save() {
      // console.log(this.addBaseStudentForm.campus);
      this.$refs.addBaseStudentRef.validate((valid) => {
        if (valid) {
          let params = new FormData(); //创建一个form对象,必须是form对象否则后端接受不到数据
          // params.append("modeSubject", this.addBaseStudentForm.modeSubject);
          // params.append("studentNumber", this.addBaseStudentForm.studentNumber);
          // params.append("password", this.addBaseStudentForm.password);
          params.append("name", this.addBaseStudentForm.name);
          // params.append("examineNumber", this.addBaseStudentForm.examineNumber);
          params.append("idCard", this.addBaseStudentForm.idCard);
          params.append("sex", this.addBaseStudentForm.sex);
          // params.append("fatherMobile", this.addBaseStudentForm.fatherMobile);
          // params.append("motherMobile", this.addBaseStudentForm.motherMobile);
          // params.append("fatherName", this.addBaseStudentForm.fatherName);
          // params.append("motherName", this.addBaseStudentForm.motherName);
          // params.append("address", this.addBaseStudentForm.address);
          // params.append("fatherWorkUnit", this.addBaseStudentForm.fatherWorkUnit);
          // params.append("motherWorkUnit", this.addBaseStudentForm.motherWorkUnit);
          // params.append("status", this.addBaseStudentForm.status);
          // params.append("createId", this.addBaseStudentForm.createId);
          // params.append("createDate", this.addBaseStudentForm.createDate);
          params.append("classId", this.addBaseStudentForm.classId);
          params.append("gradeId", this.addBaseStudentForm.gradeId);
          params.append("mobile", this.addBaseStudentForm.mobile);
          // params.append("alias", this.addBaseStudentForm.alias);
          // params.append("photo", this.addBaseStudentForm.photo);
          // params.append("politicalOutlook", this.addBaseStudentForm.politicalOutlook);
          // params.append("incomeDate", this.addBaseStudentForm.incomeDate);
          // params.append("nation", this.addBaseStudentForm.nation);
          // params.append("graduateSchool", this.addBaseStudentForm.graduateSchool);
          // params.append("admissionScore", this.addBaseStudentForm.admissionScore);
          // params.append("type", this.addBaseStudentForm.type);
          // params.append("incomeCode", this.addBaseStudentForm.incomeCode);
          // params.append("beforeName", this.addBaseStudentForm.beforeName);
          // params.append("nationality", this.addBaseStudentForm.nationality);
          // params.append("modeStudy", this.addBaseStudentForm.modeStudy);
          // params.append("oneCardNumber", this.addBaseStudentForm.oneCardNumber);
          // params.append("dormitoryNumber", this.addBaseStudentForm.dormitoryNumber);
          // params.append("englishName", this.addBaseStudentForm.englishName);
          // params.append("studentType", this.addBaseStudentForm.studentType);
          params.append("campus", this.addBaseStudentForm.campus);
          // params.append("scoreStatistics", this.addBaseStudentForm.scoreStatistics);
          // params.append("modeOfStudy", this.addBaseStudentForm.modeOfStudy);
          // params.append("isDelete", this.addBaseStudentForm.isDelete);
          if (this.addBaseStudentForm.id) {
            params.append("id", this.addBaseStudentForm.id);
            params.append("status", this.addBaseStudentForm.status);
            if (this.oldGradeId === this.addBaseStudentForm.gradeId) {
              httpService("/javaApi/baseStudent/edit", params, "post").then(
                (data) => {
                  if (data.code == 200) {
                    ElMessage.success("修改成功");
                    this.clear();
                    //刷新父组件的数据
                    this.$parent.getBaseStudentList();
                  } else {
                    ElMessage.error("修改失败");
                  }
                }
              );
            } else {
              ElMessageBox.confirm(
                "跨年级转班会生成新的学号，原学号将丢失，确定要跨年级转班吗？",
                "提醒",
                {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                }
              )
                .then(() => {
                  httpService("/javaApi/baseStudent/edit", params, "post").then(
                    (data) => {
                      if (data.code == 200) {
                        ElMessage.success("修改成功");
                        this.clear();
                        //刷新父组件的数据
                        this.$parent.getBaseStudentList();
                      } else {
                        ElMessage.error("修改失败");
                      }
                    }
                  );
                })
                .catch(() => { });
            }
          } else {
            httpService("/javaApi/baseStudent/add", params, "post").then(
              (data) => {
                if (data.code == 200) {
                  ElMessage.success("添加成功");
                  this.clear();
                  //刷新父组件的数据
                  this.$parent.getBaseStudentList();
                } else {
                  ElMessage.error("添加失败");
                }
              }
            );
          }
        } else {
          return false;
        }
      });
    },
  },
};
</script>
<style>
.el-select {
  width: 100%;
}

.el-dialog__header {
  padding: var(--el-dialog-padding-primary);
  padding-bottom: 10px;
  border-bottom: 1px solid #dedede;
  margin-bottom: 10px;
}
</style>